<template>
  <div class="pageWrapper">
    <common-header />
    <van-tabs v-if="ready" v-model="active" color="#1B68EB" sticky :offset-top="isDD ? 0 : '1.33333rem'" title-inactive-color="#CCCCCC" title-active-color="#1F1F1F" :line-width="58" :line-height="2">
      <van-tab title="我的记实">
        <my-report v-if="showReport" />
      </van-tab>
      <van-tab title="业绩晾晒">
        <achievement />
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import achievement from "../components/achievement.vue";
import myReport from "../components/my-report.vue";
import { mapState } from "vuex";
export default {
  name: "NormalReport",
  components: {
    myReport,
    achievement
  },
  computed: {
    ...mapState({
      isDD: state => state.user.is_dd
    })
  },
  beforeRouteEnter(to, from, next) {
    if (from.name == "Normal" || !from.name) {
      next(vm => {
        vm.active = 0;
        vm.ready = false;
        vm.$nextTick(() => {
          vm.ready = true;
        });
      });
    } else {
      next(vm => {
        vm.ready = true;
        if (vm.active == 0) {
          vm.showReport = false;
          vm.$nextTick(() => {
            vm.showReport = true;
          });
        }
      });
    }
  },
  data() {
    return {
      active: 0,
      ready: false,
      showReport: true
    };
  }
};
</script>

<style scoped lang="scss"></style>
